package com.wwc.business.controller;

import com.wwc.business.controller.dto.train_carriage.TrainCarriageDeleteDTO;
import com.wwc.business.controller.dto.train_carriage.TrainCarriageInsertDTO;
import com.wwc.business.controller.dto.train_carriage.TrainCarriageSelectListDTO;
import com.wwc.business.controller.dto.train_carriage.TrainCarriageUpdateDTO;
import com.wwc.business.controller.vo.TrainCarriageSelectListVO;
import com.wwc.business.service.ITrainCarriageService;
import com.wwc.common.response.CommonResponse;
import com.wwc.common.response.PageResponse;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.*;

/**
 * 火车车厢 Controller
 */
@RestController
@RequestMapping("/admin/train-carriage")
public class TrainCarriageController{
	@Resource
	private ITrainCarriageService trainCarriageService;

	/**
	 * 新增火车车厢
	 */
	@PostMapping("/insert")
	public CommonResponse<?> insert(@Valid @RequestBody TrainCarriageInsertDTO trainCarriageInsertDTO){
		trainCarriageService.insert(trainCarriageInsertDTO);
		return new CommonResponse<>();
	}

	/**
	 * 更新火车车厢
	 */
	@PostMapping("/update")
	public CommonResponse<?> update(@Valid @RequestBody TrainCarriageUpdateDTO trainCarriageUpdateDTO){
		trainCarriageService.update(trainCarriageUpdateDTO);
		return new CommonResponse<>();
	}

	/**
	 * 删除火车车厢
	 */
	@PostMapping("/delete")
	public CommonResponse<?> delete(@Valid @RequestBody TrainCarriageDeleteDTO trainCarriageDeleteDTO){
		trainCarriageService.delete(trainCarriageDeleteDTO);
		return new CommonResponse<>();
	}

	/**
	 * 查询火车车厢分页列表
	 */
	@GetMapping("/select-list-page")
	public CommonResponse<PageResponse<TrainCarriageSelectListVO>> selectListPage(@Valid TrainCarriageSelectListDTO trainCarriageSelectListDTO){
		PageResponse<TrainCarriageSelectListVO> pageResponse = trainCarriageService.selectListPage(trainCarriageSelectListDTO);
		return new CommonResponse<>(pageResponse);
	}
}